package com.aurora.demo.api;

import com.aurora.demo.api.param.QueryParam;
import com.aurora.demo.entity.Thumb;
import com.aurora.demo.service.MetaService;
import com.aurora.demo.service.ThumbService;
import com.aurora.demo.util.Result;
import com.aurora.demo.util.ResultGenerator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "2.缩略图相关接口")
@RestController
@RequestMapping("/Thumb")
public class ThumbController {

    @Autowired
    private MetaService metaService;

    @Autowired
    private ThumbService thumbService;

    @ApiOperation(value = "根据条件查找缩略图")
    @GetMapping("/find")
    public Result<List<Thumb>> findByParam(QueryParam queryParam) {
        System.out.println(queryParam.toString());
        List<String> names = metaService.getNameBySelective(queryParam);
        List<Thumb> thumbs = thumbService.findByName(names);
        return ResultGenerator.genSuccessResult(thumbs);
    }
}
